package com.ykdl.member.kid.circle;

import java.util.ArrayList;
import android.R.integer;
import android.os.Bundle;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import com.lidroid.xutils.BitmapUtils;
import com.ykdl.member.kid.R;
import com.ykdl.member.kid.beans.Icon_file_metaBean;
import com.ykdl.member.kid.beans.TopicBean;
import com.ykdl.member.kid.circle.TopicAndResultActivity.TopicResultAdapter.ViewHolder;
import com.ykdl.member.kid.gears.BaseScreen;
import com.ykdl.member.kid.image.ImageLoader;
import com.ykdl.member.kid.image.ImageOptionsFactory;
import com.ykdl.member.kid.models.FileMetas;
import com.ykdl.member.kid.widget.AsyncImageView;
import com.ykdl.member.views.HackyViewPager;
import com.ykdl.member.views.PhotoView;

public class LookImageActivity extends BaseScreen{
	private ArrayList<FileMetas> image_list ;
	private BitmapUtils bitmapUtil ;
	private ViewPager mViewPager;
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		bitmapUtil = new BitmapUtils(this);
		image_list =  (ArrayList<FileMetas>) getIntent().getSerializableExtra("list");
		int item = getIntent().getIntExtra("position", 0);
		mViewPager = new HackyViewPager(this);
		mViewPager.setAdapter(new SamplePagerAdapter());
		mViewPager.setCurrentItem(item);
		setContentView(mViewPager);
		mViewPager.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				LookImageActivity.this.finish();	
			}
		});
		
		}
	private class SamplePagerAdapter extends PagerAdapter {

		@Override
		public int getCount() {
			if (image_list!=null) {
				return image_list.size();
			}else {
				return 0;
			}
		}

		@Override
		public View instantiateItem(ViewGroup container, int position) {
			PhotoView photoView = new PhotoView(container.getContext());
			String url = image_list.get(position).getDownload_urls().getOrigin().getUrl();
			bitmapUtil.display(photoView, url);
			container.addView(photoView, LayoutParams.FILL_PARENT,
					LayoutParams.FILL_PARENT);

			return photoView;
		}

		@Override
		public void destroyItem(ViewGroup container, int position, Object object) {
			container.removeView((View) object);
		}

		@Override
		public boolean isViewFromObject(View view, Object object) {
			return view == object;
		}

	}
	
}
